package tdd.refactor;

public class TaxiFeeModel {
	protected int daytimeStartTime;
	protected int nightStartTime;
	protected int startMiles;
	protected double pricePerMile;
	protected double startPrice;
	
	TaxiFeeModel() {}

	/**
	 * @param daytimeStartTime
	 * @param nightStartTime
	 * @param startMiles
	 */
	public TaxiFeeModel(int daytimeStartTime, int nightStartTime, int startMiles) {
		this.daytimeStartTime = daytimeStartTime;
		this.nightStartTime = nightStartTime;
		this.startMiles = startMiles;
		this.pricePerMile = 0;
		this.startPrice = 0;
	}
	
	boolean isInvalidTime(int time) {
		if(time<0||time>24) {
			return true;
		} else {
			return false;
		}
	}
	
	public void init(int time, TimeFee timeFee, JudgeTime judgeTime) {
		if(isInvalidTime(time)) {
			System.out.println("invalid time!!\n");
			return;
		}	
		if(judgeTime.isDaylight(time, this)) {
			initDaylightCharge(timeFee);
		} else {
			initNightCharge(timeFee);
		}
	}

	private void initDaylightCharge(TimeFee timeFee) {
		this.pricePerMile = timeFee.daylightPricePerMile;
		this.startPrice = timeFee.daylightstartPrice;
	}
	
	private void initNightCharge(TimeFee timeFee) {
		this.pricePerMile = timeFee.nightPricePerMile;
		this.startPrice = timeFee.nightstartPrice;
	}	
}
